package com.simple.portal.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.simple.base.dao.BaseDAO;
import com.simple.portal.dao.IPartnerDAO;
import com.simple.portal.vo.PartnerVO;
import com.simple.util.common.Constants;

@Repository("partnerDAO")
public class PartnerDAOImpl extends BaseDAO implements IPartnerDAO {

	@Override
	public PartnerVO findById(final String id) {
		return super.get(PartnerVO.class, id);
	}

	@Override
	public void save(final PartnerVO partnerVO,final String operator) {
		PartnerVO tempPartnerVO = super.save(partnerVO);
		super.saveLogger(operator, tempPartnerVO, tempPartnerVO.getPartnerId(),Constants.LOGGER_OPERATE_FLAG_ADD);
	}
	
	@Override
	public void update(final PartnerVO partnerVO,final String type,final String operator) {
		super.update(partnerVO);
		super.saveLogger(operator, partnerVO, partnerVO.getPartnerId(),type);
	}

	@Override
	public List<PartnerVO> findAll() {
		return super.query(PartnerVO.class);
	}

	@Override
	public void delete(final PartnerVO partnerVO,final String operator) {
		super.delete(partnerVO);
		super.saveLogger(operator, partnerVO, partnerVO.getPartnerId(), Constants.LOGGER_OPERATE_FLAG_DELETE);
	}

	@Override
	public void delete(final String id,final String operator) {
		PartnerVO partnerVO = findById(id);
		super.delete(PartnerVO.class, id);
		super.saveLogger(operator, partnerVO, partnerVO.getPartnerId(), Constants.LOGGER_OPERATE_FLAG_DELETE);
	}

}
